package com.ruoyi.game.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.game.domain.GameRoomPlayerPos;
import com.ruoyi.game.service.IGameRoomPlayerPosService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房间座位Controller
 * 
 * @author ruoyi
 * @date 2025-04-18
 */
@RestController
@RequestMapping("/game/pos")
public class GameRoomPlayerPosController extends BaseController
{
    @Autowired
    private IGameRoomPlayerPosService gameRoomPlayerPosService;

    /**
     * 查询房间座位列表
     */
    // @PreAuthorize("@ss.hasPermi('game:pos:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameRoomPlayerPos gameRoomPlayerPos)
    {
        startPage();
        List<GameRoomPlayerPos> list = gameRoomPlayerPosService.selectGameRoomPlayerPosList(gameRoomPlayerPos);
        return getDataTable(list);
    }

    /**
     * 导出房间座位列表
     */
    // @PreAuthorize("@ss.hasPermi('game:pos:export')")
    @Log(title = "房间座位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameRoomPlayerPos gameRoomPlayerPos)
    {
        List<GameRoomPlayerPos> list = gameRoomPlayerPosService.selectGameRoomPlayerPosList(gameRoomPlayerPos);
        ExcelUtil<GameRoomPlayerPos> util = new ExcelUtil<GameRoomPlayerPos>(GameRoomPlayerPos.class);
        util.exportExcel(response, list, "房间座位数据");
    }

    /**
     * 获取房间座位详细信息
     */
    // @PreAuthorize("@ss.hasPermi('game:pos:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gameRoomPlayerPosService.selectGameRoomPlayerPosById(id));
    }

    /**
     * 新增房间座位
     */
    // @PreAuthorize("@ss.hasPermi('game:pos:add')")
    @Log(title = "房间座位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameRoomPlayerPos gameRoomPlayerPos)
    {
        return toAjax(gameRoomPlayerPosService.insertGameRoomPlayerPos(gameRoomPlayerPos));
    }

    /**
     * 修改房间座位
     */
    // @PreAuthorize("@ss.hasPermi('game:pos:edit')")
    @Log(title = "房间座位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameRoomPlayerPos gameRoomPlayerPos)
    {
        return toAjax(gameRoomPlayerPosService.updateGameRoomPlayerPos(gameRoomPlayerPos));
    }

    /**
     * 删除房间座位
     */
    // @PreAuthorize("@ss.hasPermi('game:pos:remove')")
    @Log(title = "房间座位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gameRoomPlayerPosService.deleteGameRoomPlayerPosByIds(ids));
    }
}
